package com.tcm.day06;

/**
 * 相同的树
 * https://leetcode.cn/problems/same-tree/description/?envType=problem-list-v2&envId=binary-tree
 */
public class Code02_SameTree {

    public boolean isSameTree(TreeNode p, TreeNode q) {

        if (p == null ^ q == null) {
            return false;
        }

        if (p == null && q == null) {
            return true;
        }

        return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }

}
